<template>
  <el-dialog title="粉丝查询" :close-on-click-modal="false" :visible.sync="visible" fullscreen center append-to-body>
    <el-button class="miui-dialog-close-btn" @click="visible = false">关闭页面</el-button>
    <el-card class="box-card" style="margin-bottom: 15px;">
      <div class="text item">
        <el-form inline label-width="70px">
          <el-form-item label="粉丝名称">
            <el-input v-model="dataForm.personName"></el-input>
          </el-form-item>
          <el-form-item label="联系电话">
            <el-input v-model="dataForm.telPhone"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button icon="el-icon-search" type="primary" @click="searchHandle">查询</el-button>
            <el-button icon="el-icon-delete" type="info" @click="clearSearchForm">清空</el-button>
          </el-form-item>
        </el-form>
      </div>
    </el-card>
    <el-table :data="dataList" height="calc(100vh - 215px)" ref="singleTable" border header-cell-class-name="miui-header-cell-style" v-loading="dataListLoading">
      <el-table-column type="index" width="50">
        <template slot-scope="scope">
          <el-radio v-model="dataForm.personId" :label="scope.row.id" style="position: relative;left: 6px;top:-2px;" @change="checkFens(scope.row)">&nbsp;</el-radio>
        </template>
      </el-table-column>
      <el-table-column prop="customerCard" header-align="center" align="center" label="粉丝卡号"></el-table-column>
      <el-table-column prop="personName" header-align="center" align="center" label="粉丝姓名"></el-table-column>
      <el-table-column prop="telPhone" header-align="center" align="center" label="联系电话"></el-table-column>
    </el-table>
    <div class="avue-crud__pagination">
      <el-pagination
        @size-change="sizeChangeHandle"
        @current-change="currentChangeHandle"
        :current-page="pageIndex"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="pageSize"
        :total="totalPage"
        background
        layout="total, sizes, prev, pager, next">
      </el-pagination>
    </div>
  </el-dialog>
</template>

<script>
  import { getFansList } from '@/api/mp/fansexchangelog'
  export default {
    data () {
      return {
        visible: false,
        personId: '',
        dataForm: {},
        dataList: [],
        dataListLoading: false,
        pageIndex: 1,
        pageSize: 100,
        totalPage: 0
      }
    },
    methods: {
      init () {
        this.visible = true
        for(let key in this.dataForm){
          this.dataForm[key] = ''
        }
        this.getFansList()
      },
      //  查询数据
      searchHandle() {
        this.pageIndex = 1
        this.getFansList()
      },
			//	清空查询表单
			clearSearchForm() {
				for(let key in this.dataForm){
					this.dataForm[key] = ''
				}
			},
      // 获取粉丝列表
      getFansList() {
        let params = {current: this.pageIndex,size: this.pageSize}
        getFansList(Object.assign(params,this.dataForm)).then(result => {
            // this.dataList = result.data.data.records
            // this.totalPage = result.data.data.total
        })
      },
      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getFansList()
      },
      // 当前页
      currentChangeHandle (val) {
        this.pageIndex = val
        this.getFansList()
      },
      // 选择投诉会员
      checkFens(val) {
        this.visible = false
        this.$emit('refreshForm',val)
      },
    }
  }
</script>

<style>
</style>
